---
- name: Install WireGuard on Almalinux 9
  gather_facts: true
  hosts: vpn
  become: true
  tasks:
    - name: Set hostname
      ansible.builtin.hostname:
        name: "{{ inventory_hostname }}"
#        use: systemd

    - name: Disable selinux
      ansible.posix.selinux:
        state: disabled

    - name: Set sysctl params
      ansible.posix.sysctl:
        name: 'net.ipv4.ip_forward'
        value: '1'
        sysctl_set: true
        state: present
        reload: true
        sysctl_file: /etc/sysctl.conf

    - name: Load wireguard modules
      ansible.builtin.shell: |
        modprobe wireguard

    - name: Autoload the wireguard module
      ansible.builtin.blockinfile:
        path: /etc/modules-load.d/wireguard.conf
        create: true
        block: |
          wireguard

    - name: Install 
      ansible.builtin.dnf:
        name:
          - wireguard-tools
        state: present    